package com.hamizhong.iflowers.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeanUtils;

import com.hamizhong.iflowers.db.dao.hibernate.ICityDao;
import com.hamizhong.iflowers.db.dao.hibernate.IProvinceDao;
import com.hamizhong.iflowers.db.entity.Province;
import com.hamizhong.iflowers.service.IProvinceService;
import com.hamizhong.iflowers.service.base.MyBaseService;
import com.hamizhong.iflowers.web.dto.IOPResultDto;
import com.hamizhong.iflowers.web.vo.IObjectVO;
import com.hamizhong.iflowers.web.vo.ProvinceVO;

public class ProvinceServiceImpl extends MyBaseService implements IProvinceService {

	private IProvinceDao iProvinceDao = null;
	private ICityDao iCityDao = null;

	public IProvinceDao getiProvinceDao() {
		return iProvinceDao;
	}
	public void setiProvinceDao(IProvinceDao iProvinceDao) {
		this.iProvinceDao = iProvinceDao;
	}
	public ICityDao getiCityDao() {
		return iCityDao;
	}
	public void setiCityDao(ICityDao iCityDao) {
		this.iCityDao = iCityDao;
	}
	
	public IOPResultDto<IObjectVO> findAll() {
		IOPResultDto<IObjectVO> dto = new IOPResultDto<IObjectVO>();
		List<Province> provinceList = iProvinceDao.findAll();
		List<ProvinceVO> provinceVOList = new ArrayList<ProvinceVO>();
		ProvinceVO provinceVO = null;
		for (Province province : provinceList) {
			provinceVO = new ProvinceVO();
			BeanUtils.copyProperties(province, provinceVO);
			provinceVOList.add(provinceVO);
		}
		IObjectVO iObjectVO = new IObjectVO();
		iObjectVO.setProvinceVOList(provinceVOList);
		dto.addToResultList(iObjectVO);
		dto.setSuccess(true);
		return dto;
	}
	
	
}
